/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : Win15Pic_720P.c /Project:AVOS		       **
**        Revision : 1.0                                       	**
**                                                             	**
*****************************************************************/
#include "../menu.h"
#include "Win15PicEvent.h"
#include "./win/NetmenuSetupEvent.h"
extern int TOP;
INT32S Win15Pic_720PMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type)
    {
        case WM_SHOWWINDOW:
        return Win15PicOnShow(hwnd, lpParam) ;
    }
    return 0 ;
}
INT32S Win15PicBar_720PMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_SHOWWINDOW:
            return Win15PicBarOnShow(hwnd, lpParam) ;
        case WM_KEYDOWN:
            return Win15PicBarOnKeyPress(hwnd, lpParam) ;
    }
    return 0 ;
}

void SetWin15Pic_720PPalette(void)
{
    YUVENTRY mask_para[4] = {0,4095,4095,4095};
    AWSetAlphaMask(0,4, mask_para);
    YUVENTRY palette_para[16] = {0x8000 | 16392,0x8000 | 16216,0x8000 | 17880,0x8000 | 16392,16280,16184,16088,16040,16024,15880,15208,15720,15016,15064,15304,15144};
    AWSetPalette(0,16, palette_para);
    return ;
}

void SetWin15Pic_720PPos(HWND* pControl, INT8U CurOsdSize)
{
    switch(CurOsdSize)
      {
		 default:     	
    		RECT NormalWindowRect = {0,0,1280,720};
            pControl->winrect = NormalWindowRect;
            CREATEWINDOWPARAM NormalWindowPara = {1,{{0,0,1280,720},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{0,0,0,0},SetWin15Pic_720PPalette};
            AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&NormalWindowPara);
    	   	break;
        
      }
       
 
    return;
}

HWND *CreateControlWin15Pic_720P(HWND* pParent)
{
    HWND* pNewControl;
    CREATEWINDOWPARAM window_para = {1,{{0,0,1280,720},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{PF_PALETTE_256,0,0,0},SetWin15Pic_720PPalette};
    //Create Menu Window -- 1
    pNewControl = AWCreateWinControl("TWindow","Win15Pic_720P",WS_OVERLAPPEDWINDOW,
		         0,0,1280,720,NULL, (INT32S)&window_para,Win15Pic_720PMsgProc) ;
    pNewControl->win_id = 0 ;
    return pNewControl;
}


void Set15PicBar_720PPos(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
    		pControl->winrect.top = pControl->parent->winrect.top + 0;
            pControl->winrect.left = pControl->parent->winrect.left + 0;
            pControl->winrect.width = 1280;
            pControl->winrect.height = 720;
            pControl->draw_info_num = 57;
            RECT StandardRect[57] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,1280,720},
            {pControl->winrect.left + 30,pControl->winrect.top + 6,120,78},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 146,136,78},
            {pControl->winrect.left + 220,pControl->winrect.top + 146,136,78},
            {pControl->winrect.left + 360,pControl->winrect.top + 146,136,78},
            {pControl->winrect.left + 500,pControl->winrect.top + 146,136,78},
            {pControl->winrect.left + 640,pControl->winrect.top + 146,136,78},
            {pControl->winrect.left + 780,pControl->winrect.top + 146,136,78},
            {pControl->winrect.left + 920,pControl->winrect.top + 146,136,78},
            {pControl->winrect.left + 1060,pControl->winrect.top + 146,136,78},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 226,136,78},
            {pControl->winrect.left + 220,pControl->winrect.top + 226,136,78},
            {pControl->winrect.left + 360,pControl->winrect.top + 226,136,78},
            {pControl->winrect.left + 500,pControl->winrect.top + 226,136,78},
            {pControl->winrect.left + 640,pControl->winrect.top + 226,136,78},
            {pControl->winrect.left + 780,pControl->winrect.top + 226,136,78},
            {pControl->winrect.left + 920,pControl->winrect.top + 226,136,78},
            {pControl->winrect.left + 1060,pControl->winrect.top + 226,136,78},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 306,136,78},
            {pControl->winrect.left + 220,pControl->winrect.top + 306,136,78},
            {pControl->winrect.left + 360,pControl->winrect.top + 306,136,78},
            {pControl->winrect.left + 500,pControl->winrect.top + 306,136,78},
            {pControl->winrect.left + 640,pControl->winrect.top + 306,136,78},
            {pControl->winrect.left + 780,pControl->winrect.top + 306,136,78},
            {pControl->winrect.left + 920,pControl->winrect.top + 306,136,78},
            {pControl->winrect.left + 1060,pControl->winrect.top + 306,136,78},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 386,136,78},
            {pControl->winrect.left + 220,pControl->winrect.top + 386,136,78},
            {pControl->winrect.left + 360,pControl->winrect.top + 386,136,78},
            {pControl->winrect.left + 500,pControl->winrect.top + 386,136,78},
            {pControl->winrect.left + 640,pControl->winrect.top + 386,136,78},
            {pControl->winrect.left + 780,pControl->winrect.top + 386,136,78},
            {pControl->winrect.left + 920,pControl->winrect.top + 386,136,78},
            {pControl->winrect.left + 1060,pControl->winrect.top + 386,136,78},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 466,136,78},
            {pControl->winrect.left + 220,pControl->winrect.top + 466,136,78},
            {pControl->winrect.left + 360,pControl->winrect.top + 466,136,78},
            {pControl->winrect.left + 500,pControl->winrect.top + 466,136,78},
            {pControl->winrect.left + 640,pControl->winrect.top + 466,136,78},
            {pControl->winrect.left + 780,pControl->winrect.top + 466,136,78},
            {pControl->winrect.left + 920,pControl->winrect.top + 466,136,78},
            {pControl->winrect.left + 1060,pControl->winrect.top + 466,136,78},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 546,136,78},
            {pControl->winrect.left + 220,pControl->winrect.top + 546,136,78},
            {pControl->winrect.left + 360,pControl->winrect.top + 546,136,78},
            {pControl->winrect.left + 500,pControl->winrect.top + 546,136,78},
            {pControl->winrect.left + 640,pControl->winrect.top + 546,136,78},
            {pControl->winrect.left + 780,pControl->winrect.top + 546,136,78},
            {pControl->winrect.left + 920,pControl->winrect.top + 546,136,78},
            {pControl->winrect.left + 1060,pControl->winrect.top + 546,136,78},                       
                    
            {pControl->winrect.left + 1060,pControl->winrect.top + 70,128,44},
            {pControl->winrect.left + 1060,pControl->winrect.top + 80,128,44},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 645,550,28},
            {pControl->winrect.left + 80,pControl->winrect.top + 645,550,28},
            
            {pControl->winrect.left + 730,pControl->winrect.top + 645,550,28},
            
            {pControl->winrect.left + 930,pControl->winrect.top + 645,320,28},
            
            {pControl->winrect.left + 80,pControl->winrect.top + 645,550,28},
            };
            for(iLoop=0; iLoop < 57; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &StandardRect[iLoop], sizeof(RECT));
          
    TOP=GetFileNamePosition(pControl,CurOsdSize);
    return;
}

HWND *CreateControl15PicBar_720P(HWND *pParent)
{
 
    HWND *pNewControl = AWCreateWinControl("TControl","15PicBar_720P",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		         0,0,1280,720,pParent,0,Win15PicBar_720PMsgProc) ;
    pNewControl->win_id = 2 ;
    pNewControl->draw_info_num = 57;
    pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
    DRAWINFO DrawDatas[57] = {
        //{0,0,0,0,(INT32U)ICON_PHOTO_BACKGROUND,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PHOTO_TOP,DT_RLE_BMP_DATA},
        
        {0,0,0,0,(INT32U)ICON_PIC_FOCUS,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	{0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
       	
       	{0,0,0,0,(INT32U)ICON_PAGE_BACKROUNG,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_STRING_DATA},
        
        {0,0,0,0,(INT32U)ICON_PHOTO_INFO_BACKROUNG,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_STRING_DATA},
        
        {0,0,0,0,(INT32U)ICON_PHOTO_INFO_BACKROUNG,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_STRING_DATA},
        {0,0,0,0,(INT32U)0,DT_VOSD_DATA}
        };
    memcpy(pNewControl->draw_info, DrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
  
  

    return pNewControl;
}

HWND* CreateMenuWin15Pic_720P(void)
{
    HWND *pNewControl ;
    TWINDOWS *pWin;
    HWND *pWin15Pic_720P = CreateControlWin15Pic_720P(NULL);
    SetWin15Pic_720PPos(pWin15Pic_720P,CurrentOsdSize);


    pNewControl= CreateControl15PicBar_720P(pWin15Pic_720P);
    Set15PicBar_720PPos(pNewControl,CurrentOsdSize);

    pWin = (TWINDOWS *)pWin15Pic_720P;
    pWin->pFocusControl = AWFindWinCtrlByName("15PicBar_720P");
    return pWin15Pic_720P;
}

void WinResetWin15Pic_720PControlsPos(HWND *pControl, INT8U CurOsdSize)
{
    switch(pControl->win_id){
        case 0://Win15Pic_720P
            SetWin15Pic_720PPos(pControl,CurOsdSize) ;
            break ;
        case 2://15PicBar
            Set15PicBar_720PPos(pControl,CurOsdSize) ;
            break ;
    }//end of switch
}
void WinResetWin15Pic_720PPos(HWND *pControl, INT8U CurOsdSize)
{
    HWND *pChildControl;
    if(pControl == NULL)
        pControl = AWFindWinCtrlByName("Win15Pic_720P");
    if(pControl == NULL) return ;

    WinResetWin15Pic_720PControlsPos(pControl, CurOsdSize) ;
    pChildControl = pControl->children ;
    while(pChildControl != NULL){
    	WinResetWin15Pic_720PPos(pChildControl, CurOsdSize) ;
    	pChildControl = pChildControl->siblings ;
	}
	return ;
}

            	
            	
	

